package com.tanhua.server.controller;


import com.tanhua.model.vo.CallVo;
import com.tanhua.server.service.CallService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@RestController
@RequestMapping("/peachblossom")
public class CallController {

    @Autowired
    private CallService callService;


    /**
     * 发送语音
     * @return
     */
    @PostMapping
    public ResponseEntity sendCall(@RequestBody MultipartFile soundFile) throws IOException {
        callService.sendCall(soundFile);
        return ResponseEntity.ok(null);
    }

    /**
     * 接收语音
     * @return
     */
    @GetMapping
    public ResponseEntity receiveCall() {
        CallVo callVo = callService.receiveCall();
        return ResponseEntity.ok(callVo);
    }
}
